#include "KnockOutCallOption.h"

KnockOutCallOption::KnockOutCallOption() {
	strike = 0.0;
	maturity = 0.0;
	knockPrice = 0.0;
}


double KnockOutCallOption::getMaturity() const{
	return maturity;
}

void KnockOutCallOption::setStrike(double s) { strike = s; };
void KnockOutCallOption::setMaturity(double m) { maturity = m; };
void KnockOutCallOption::setKnockPrice(double p) { knockPrice = p; };

double KnockOutCallOption::payoff(std::vector<double>& prices) const{
	double lastPrice = prices[prices.size() - 1];
	if (lastPrice > strike) {
		for (auto p : prices) {
			if (p >= knockPrice) {
				return 0.0;
			}
		}
		return lastPrice - strike;
	}
	else {
		return 0.0;
	}
	double result =  - strike;
	
}